<extend name="Public/List/Common"/>
<block name="pageHeader">
    <div class="bjui-pageHeader">
        <form id="pagerForm" data-toggle="ajaxsearch" action="__ACTION__" method="post">
            <label>关键词：</label>
            <input value="{$_REQUEST['key']}" name="key" class="form-control" size="15"/>
            <button type="submit" class="btn-default" data-icon="search">查询</button>
            <a class="btn btn-orange" href="javascript:;" onclick="$(this).navtab('reloadForm', true);"
               data-icon="undo">清空查询</a>

            <div class="pull-right">
                <a href="{:U('add', array('type'=>I('type')))}" class="btn btn-green" data-toggle="dialog" title="添加">添加</a>

                <div class="btn-group">
                    <button type="button" class="btn-default dropdown-toggle" data-toggle="dropdown" data-icon="copy">
                        复选框-批量操作
                        <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu right" role="menu">
                        <li>
                            <a href="{:U('del')}" data-toggle="doajaxchecked" data-confirm-msg="确定要删除选中项吗？"
                               data-idname="id" data-group="ids">删除选中</a>
                        </li>
                    </ul>
                </div>
            </div>
        </form>
    </div>
</block>
<block name="pageContent">
    <div class="bjui-pageContent tableContent">
        <table data-toggle="tablefixed" data-width="100%" data-nowrap="true">
            <thead>
            <tr>
                <th>
                    编号
                </th>
                <th>
                    标题
                </th>
<!--                <th>
                    类型
                </th>-->
                <th>
                    位置
                </th>
                <th>
                    排序
                </th>
                <th>
                    状态
                </th>
                <th>
                    图片或logo
                </th>
                <th width="100">操作</th>
            </tr>
            </thead>
            <tbody>

            <volist name="adList" id="vo">

                <tr>
                    <td>
                        {$vo.id}
                    </td>
                    <td>
                        {$vo.title}
                    </td>
<!--                    <td>
                        {$vo.type|columnToName=AD_TYPE,###}
                    </td>-->
                    <td>
                        {$vo.position|columnToName=AD_POSITION,###}
                    </td>
                    <td>
                        {$vo.sort}
                    </td>
                    <td>
                        {$vo.status|columnToName=DEFAULE_STATUS,###}
                    </td>
                    <td>
                        <div data-toggle="upload"
                             data-uploader="{:U('upload')}"
                             data-form-data='{"field_name":"photo","id":"<?php echo $vo['id'];?>"}'
                             data-file-size-limit="1024000000"
                             data-file-type-exts="*.jpg;*.png;*.gif;*.mpg"
                             data-multi="true"
                             data-on-upload-success="custom_pic_upload_success"
                             data-icon="cloud-upload"></div>
                        <span>
                            <img width="100" src="{$vo.photo|urlAddDomain}" onerror="$(this).hide();" alt="没有图片">
                        </span>
                    </td>
                    <td>
                        <a href="{:U('edit', array('id'=>$vo['id']))}" class="btn btn-green" data-toggle="dialog"
                           data-id="dialog-normal" data-mask="true"
                           data-title="编辑">编辑</a>
                        <a href="{:U('del?id='.$vo['id'])}" class="btn btn-red"
                           data-toggle="doajax">删除</a>
                    </td>
                </tr>

            </volist>

            </tbody>
        </table>
    </div>
</block>
<block name="pageJavascript">
    <script>
        function custom_pic_upload_success(file, data, $upload) {
            console.log(file);
            console.log(data);
            console.log($upload);
            var json = $.parseJSON(data)
            if (json[BJUI.keys.statusCode] == BJUI.statusCode.ok) {
                var pic = json.filename
                $upload.next().html('<img src="' + pic + '" width="80" />')
            }else{
                $(this).alertmsg('error', '上传图片失败！')
            }
        }
    </script>
</block>